import time
import unittest
from selenium import webdriver
import DataFile


class LoginTest(unittest.TestCase):

    def setUp(self):
        '''
        测试前的准备
        :return:
        '''
        self.driver = webdriver.Chrome()
        self.driver.maximize_window()
        self.driver.implicitly_wait(8)
        self.driver.get("http://14.29.116.243:9018/login.html")

    def tearDown(self):
        '''
        测试后结束
        :return:
        '''
        # self.driver.quit()

    def test_baidu_search(self):
        """
        这里一定要test开头，把测试逻辑代码封装到一个test开头的方法里。
        :return:
        """
        print(DataFile.get_login_UserName)
        self.driver.find_element_by_xpath(DataFile.get_login_UserName).send_keys('admin')
        time.sleep(2)
        self.driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/input').send_keys('admin')
        self.driver.find_element_by_id('loginSubmit').click()
        try:
            assert 'MJN Traceability 报表平台' in self.driver.title
            print('Test Pass.')
        except Exception as e:
            print('Test Fail', format(e))


if __name__ == '__main__':
    unittest.main()


